{% if export_url %}
    {% if list_element %}
        {% if export_templates %}
            <li class="dropdown-header fs-5">Export Templates</li>
        {% endif %}
        {% if include_yaml_option %}
            <li>
                <form action="{{ export_url }}" method="post">
                    {% csrf_token %}
                    <input type="hidden" name="content_type" value="{{ content_type.pk }}">
                    <input type="hidden" name="query_string" value="{{ query_string }}">
                    <input type="hidden" name="_schedule_type" value="immediately">
                    <input type="hidden" name="export_format" value="yaml">
                    <button class="dropdown-item" type="submit">
                        <span class="mdi mdi-database-export text-secondary" aria-hidden="true"></span> Export as YAML
                    </button>
                </form>
            </li>
        {% endif %}
        <li>
            <form action="{{ export_url }}" method="post">
                {% csrf_token %}
                <input type="hidden" name="content_type" value="{{ content_type.pk }}">
                <input type="hidden" name="query_string" value="{{ query_string }}">
                <input type="hidden" name="_schedule_type" value="immediately">
                <input type="hidden" name="export_format" value="csv">
                <button class="dropdown-item" type="submit">
                    <span class="mdi mdi-database-export text-secondary" aria-hidden="true"></span> Export as CSV
                </button>
            </form>
        </li>
        {% if export_templates %}
            {% for et in export_templates %}
                <li>
                    <form action="{{ export_url }}" method="post">
                        {% csrf_token %}
                        <input type="hidden" name="content_type" value="{{ content_type.pk }}">
                        <input type="hidden" name="export_template" value="{{ et.pk }}">
                        <input type="hidden" name="query_string" value="{{ query_string }}">
                        <input type="hidden" name="_schedule_type" value="immediately">
                        <button class="dropdown-item" type="submit"
                                {% if et.description %}title="{{ et.description }}"{% endif %}
                        ><span class="mdi mdi-database-export text-secondary" aria-hidden="true"></span> {{ et.name }}</button>
                    </form>
                </li>
            {% endfor %}
        {% endif %}
    {% else %}
        {% if export_templates or include_yaml_option %}
            <div class="btn-group">
                <button type="submit" class="btn btn-success" form="export_default">
                    <span class="mdi mdi-database-export" aria-hidden="true"></span>
                    Export
                </button>
                <form id="export_default" class="d-inline-block" action="{{ export_url }}" method="post">
                    {% csrf_token %}
                    <input type="hidden" name="content_type" value="{{ content_type.pk }}">
                    <input type="hidden" name="query_string" value="{{ query_string }}">
                    <input type="hidden" name="export_format"
                           value="{% if include_yaml_option %}yaml{% else %}csv{% endif %}">
                    <input type="hidden" name="_schedule_type" value="immediately">
                </form>
                <button type="button" class="btn btn-success dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="visually-hidden">Toggle Dropdown</span>
                </button>
                <ul class="dropdown-menu dropdown-menu-end">
                    {% if include_yaml_option %}
                        <li>
                            <button type="submit" class="dropdown-item" form="export_default">Export as YAML</button>
                        </li>
                        <li>
                            <form action="{{ export_url }}" method="post">
                                {% csrf_token %}
                                <input type="hidden" name="content_type" value="{{ content_type.pk }}">
                                <input type="hidden" name="query_string" value="{{ query_string }}">
                                <input type="hidden" name="_schedule_type" value="immediately">
                                <button type="submit" class="dropdown-item">Export as CSV</button>
                            </form>
                        </li>
                    {% else %}
                        <li>
                            <button type="submit" class="dropdown-item" form="export_default">CSV format</button>
                        </li>
                    {% endif %}
                    {% if export_templates %}
                        <li class="dropdown-divider"></li>
                        {% for et in export_templates %}
                            <li>
                                <form action="{{ export_url }}" method="post">
                                    {% csrf_token %}
                                    <input type="hidden" name="content_type" value="{{ content_type.pk }}">
                                    <input type="hidden" name="export_template" value="{{ et.pk }}">
                                    <input type="hidden" name="query_string" value="{{ query_string }}">
                                    <input type="hidden" name="_schedule_type" value="immediately">
                                    <button type="submit" class="dropdown-item"
                                            {% if et.description %}title="{{ et.description }}"{% endif %}
                                    >{{ et.name }}</button>
                                </form>
                            </li>
                        {% endfor %}
                    {% endif %}
                </ul>
            </div>
        {% else %}
            <form class="d-inline-block" action="{{ export_url }}" method="post">
                {% csrf_token %}
                <input type="hidden" name="content_type" value="{{ content_type.pk }}">
                <input type="hidden" name="query_string" value="{{ query_string }}">
                <input type="hidden" name="_schedule_type" value="immediately">
                <button type="submit" class="btn btn-success">
                    <span class="mdi mdi-database-export" aria-hidden="true"></span> Export
                </button>
            </form>
        {% endif %}
    {% endif %}
{% endif %}
